/*
 * Copyright 2019-2021 shoprh.com. All rights reserved.
 * Support: http://www.shoprh.com
 * License: http://www.shoprh.com/license
 */
package com.shoprh.shop.service.impl;

import java.util.List;
import cn.hutool.core.collection.CollUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.shoprh.common.utils.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.shoprh.shop.mapper.AdPositionMapper;
import com.shoprh.shop.domain.AdPosition;
import com.shoprh.shop.service.IAdPositionService;

/**
 * Service - 广告位
 *
 * @author 若狐 Team
 * @version 1.0
 */
@Service
public class AdPositionServiceImpl extends ServiceImpl<AdPositionMapper, AdPosition> implements IAdPositionService {
    @Autowired
    private AdPositionMapper adPositionMapper;

    /**
     * 查询广告位
     * 
     * @param id 广告位ID
     * @return 广告位
     */
    @Override
    public AdPosition selectAdPositionById(Long id) {
        return adPositionMapper.selectById(id);
    }

    /**
     * 查询广告位列表
     * 
     * @param adPosition 广告位
     * @return 广告位
     */
    @Override
    public List<AdPosition> selectAdPositionList(AdPosition adPosition) {
        QueryWrapper queryWrapper = new QueryWrapper();
        if (StringUtils.isNotEmpty(adPosition.getName())) {
            queryWrapper.like("name", adPosition.getName());
        }
        return adPositionMapper.selectList(queryWrapper);
    }

    /**
     * 新增广告位
     * 
     * @param adPosition 广告位
     * @return 结果
     */
    @Override
    public int insertAdPosition(AdPosition adPosition) {
        return adPositionMapper.insert(adPosition);
    }

    /**
     * 修改广告位
     * 
     * @param adPosition 广告位
     * @return 结果
     */
    @Override
    public int updateAdPosition(AdPosition adPosition) {
        return adPositionMapper.updateById(adPosition);
    }

    /**
     * 删除广告位对象
     * 
     * @param ids 需要删除的数据ID
     * @return 结果
     */
    @Override
    public int deleteAdPositionByIds(String ids) {
        return adPositionMapper.deleteBatchIds(CollUtil.toList(ids));
    }

}
